package com.sunfield.windpower.activity;

import android.text.TextUtils;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.sunfield.baseframe.base.BaseActivity;
import com.sunfield.windpower.R;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.Extra;
import org.androidannotations.annotations.ViewById;

/**
 * Created by wxl on 2017/4/25.
 */
@EActivity(R.layout.activity_web_api)
public class WebViewActivity extends BaseActivity {
    @ViewById
    WebView webView;
    @Extra
    String url;
    @Extra
    String title;

    @AfterViews
    void init() {
        webView=(WebView) findViewById(R.id.webView);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true;
            }
        });

        if(!TextUtils.isEmpty(url)){
            webView.loadUrl(url);
        }
        setTitleText(title);
    }
}
